#pragma once

#include "Containers/SharedObjectPtr.h"
#include "Containers/WeakObjectPtr.h"
#include "Object/NewObjectInner.h"

#ifdef USING_SOURCE_LOCATION
	#include <source_location>
#endif

template<typename RObjectType>
TSharedObjectPtr<RObjectType> NewObject(CClass* InClass,RObject* InOwner=nullptr
#ifdef USING_SOURCE_LOCATION
        ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
    )
{
    return TSharedObjectPtr<RObjectType>(NewObjectInner<RObjectType>(InClass,InOwner
    #ifdef USING_SOURCE_LOCATION
    ,CreateLocation
#endif
    ));
}





template<typename RObjectType,typename OuterType>
TSharedObjectPtr<RObjectType> NewObject(
    CClass* InClass
    ,TSharedObjectPtr<OuterType> InOwner
#ifdef USING_SOURCE_LOCATION
        ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
    )
{
    return TSharedObjectPtr<RObjectType>(NewObjectInner<RObjectType>(InClass,InOwner.Get()
#ifdef USING_SOURCE_LOCATION
    ,CreateLocation
#endif
    ));
}

template<typename RObjectType>
TSharedObjectPtr<RObjectType> NewObject(RObject* InOwner
#ifdef USING_SOURCE_LOCATION
        ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
)
{
    return TSharedObjectPtr<RObjectType>(NewObjectInner<RObjectType>(InOwner
#ifdef USING_SOURCE_LOCATION
    ,CreateLocation
#endif
    ));
}

template<typename RObjectType>
TSharedObjectPtr<RObjectType> NewObject(
#ifdef USING_SOURCE_LOCATION
        const std::source_location& CreateLocation = std::source_location::current()
#endif   
)
{
    return TSharedObjectPtr<RObjectType>(NewObjectInner<RObjectType>(nullptr
#ifdef USING_SOURCE_LOCATION
    ,CreateLocation
#endif
    ));
}

template<typename RObjectType,typename OuterType>
TSharedObjectPtr<RObjectType> NewObject(TSharedObjectPtr<OuterType> InOwner
#ifdef USING_SOURCE_LOCATION
    ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
)
{
    return TSharedObjectPtr<RObjectType>(NewObjectInner<RObjectType>(InOwner.Get()
#ifdef USING_SOURCE_LOCATION
    ,CreateLocation
#endif
    ));
}

template<typename RObjectType,typename OuterType>
TSharedObjectPtr<RObjectType> NewObject(TWeakObjectPtr<OuterType> InOwner
#ifdef USING_SOURCE_LOCATION
        ,const std::source_location& CreateLocation = std::source_location::current()
#endif   
)
{
    return TSharedObjectPtr<RObjectType>(NewObjectInner<RObjectType>(InOwner.Get()
#ifdef USING_SOURCE_LOCATION
    ,CreateLocation
#endif
    ));
}

